import Vue from 'vue'
import VueRouter from 'vue-router'

const Review = () => import ('../views/nextview/Review.vue')
const Collect = () => import ('../views/collect/Collect.vue')
const Study = () => import ('../views/study/Study.vue')
const News = () => import ('../views/newsLetter/News.vue')
// const Detail = () => import ('../views/detail/Detail.vue')
// 懒加载要合理运用
import Detail from '../views/detail/Detail.vue'
const Users = () => import ('../views/users/Users.vue')


Vue.use(VueRouter)

// const routerReplace = VueRouter.prototype.replace
// VueRouter.prototype.replace = function replace(location) {
//     return routerReplace.call(this, location).catch(error => error)
// }

const routes = [
  {
    path:'',
    redirect: '/review'
  },{
    path:'/review',
    component:Review,
    name:'Review'
  },{
    path:'/collect',
    component:Collect,
    name:Collect
  },{
    path:'/study',
    component:Study,
    name:'Study'
  },{
    path:'/news',
    component:News,
    name:'News'
  },{
    path:'/users',
    component:Users,
    name:'Users'
  },{
    path:'/detail/:iid',
    component:Detail,
    name:'Detail'
  }

  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  // {
  //   path: '/about',
  //   name: 'About',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
